home *** CD-ROM | disk | FTP | other *** search
/ Web3D Graphics - Virtual Worlds Created With VRML / Web3D Graphics - Virtual Worlds Created With VRML.iso / List / AppA / Switch.java < prev    next >
Encoding:
Java Source  |  2000-12-31  |  1.7 KB  |  58 lines

  1. import vrml.*;
  2. import vrml.field.*;
  3. import vrml.node.*;
  4.  
  5. /* âgâOâïüEâXâCâbâ`ùpé╠éiéüéûéüé╔éµéΘâXâNâèâvâgɺîΣ */
  6. public class Switch extends Script {
  7.     private SFBool onOff_changed;
  8.     private SFBool areaOver;
  9.     private SFBool status;
  10.  
  11.     /*  Åëè·ë╗âüâ\âbâh  */
  12.     public void initialize() {
  13.         onOff_changed
  14.                   =(SFBool) getEventOut("onOff_changed");
  15.         areaOver=(SFBool)getField("areaOver");
  16.         status=(SFBool)getField("status");
  17.     }
  18.  
  19.     /*  âCâxâôâgÅêù¥âüâ\âbâh  */
  20.     public void processEvents(int count,Event[] es) {
  21.         int i;
  22.         for(i=0;i<count;i++){
  23.             if(es[i].getName().equals("set_onOff")
  24.                                                  ==true){
  25.                 set_onOff((ConstSFBool)es[i].getValue());
  26.             }
  27.             else if(es[i].getName().equals("set_throw")
  28.                                                  ==true){
  29.                 set_throw((ConstSFBool)es[i].getValue());
  30.             }
  31.         }
  32.     }
  33.  
  34.     /*  éôéàéöüQéÅéÄénéåéåâüâ\âbâhü@*/
  35.     private void set_onOff(ConstSFBool v){
  36.         boolean value=v.getValue();
  37.         if(value==false && areaOver.getValue()==true){
  38.             if(status.getValue()==false){
  39.                 status.setValue(true);
  40.             }
  41.             else{
  42.                 status.setValue(false);
  43.             }
  44.             onOff_changed.setValue(status.getValue());
  45.         }
  46.     }
  47.  
  48.     /*ü@éôéàéöüQéöéêéÆéÅéùâüâ\âbâhü@*/
  49.     private void set_throw(ConstSFBool v){
  50.         boolean value=v.getValue();
  51.         if(value==false){
  52.             areaOver.setValue(false);
  53.         }
  54.         else{
  55.             areaOver.setValue(true);
  56.         }
  57.     }
  58. }